﻿using System.Collections.Generic;
using System.Linq;
using ALC.Core.Enums;
using MeasurementCommon.Fai;
using WPFCommon.ViewModels.Base;

namespace ALC.Core.ViewModels.Workpiece
{
    public sealed class WorkpieceViewModel : ViewModelBase
    {
        #region props

        public IList<FaiItem> FaiItems { get; set; }

        public string Code1 { get; set; }

        public string Code2 { get; set; }

        public CavityType Cavity { get; set; }
    
        public WorkpieceResult Result { get; set; }

        public bool IsActive { get; set; } = false;

        #endregion

        #region api

        public void EvaluateResult()
        {
            Result = FaiItems.All(item => item.ValueState == ValueState.Normal) ? WorkpieceResult.Ok : WorkpieceResult.Ng;
        }

        #endregion
    }
}